package ro.toporjinschi.anytaxi.database.beans;

import ro.toporjinschi.androidorm.Entity;
import ro.toporjinschi.androidorm.annotation.Column;
import ro.toporjinschi.androidorm.annotation.Id;
import ro.toporjinschi.androidorm.annotation.NamedQueries;
import ro.toporjinschi.androidorm.annotation.NamedQuery;
import ro.toporjinschi.androidorm.annotation.TableName;
import ro.toporjinschi.anytaxi.R;

@TableName("places")
@NamedQueries({ @NamedQuery(name = "findAll", sql = "SELECT * FROM places"), @NamedQuery(name = "findById", sql = "SELECT * FROM places WHERE id = {id}"),
        @NamedQuery(name = "findByTown", sql = "SELECT * FROM places WHERE town = {town}") })
public class Place implements Entity, ArrayAdapaterView {
    @Id
    @Column
    private Integer id;
    @Column
    private String town;
    @Column
    private String streat;
    @Column
    private Integer no;
    @Column
    private String building;
    @Column
    private String stairs;
    @Column
    private Integer zipCode;
    @Column
    private String details;
    @Column
    private String title;

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTown() {
        return this.town;
    }

    public void setTown(String town) {
        this.town = town;
    }

    public String getStreat() {
        return this.streat;
    }

    public void setStreat(String streat) {
        this.streat = streat;
    }

    public Integer getNo() {
        return this.no;
    }

    public void setNo(Integer no) {
        this.no = no;
    }

    public String getBuilding() {
        return this.building;
    }

    public void setBuilding(String building) {
        this.building = building;
    }

    public String getStairs() {
        return this.stairs;
    }

    public void setStairs(String stairs) {
        this.stairs = stairs;
    }

    public Integer getZipCode() {
        return this.zipCode;
    }

    public void setZipCode(Integer zipCode) {
        this.zipCode = zipCode;
    }

    public String getDetails() {
        return this.details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public String getBeanValueFor(int layoutId, int layoutViewId) {
        if (layoutId == R.layout.element_places_view) {
            if (layoutViewId == R.id.title) {
                return this.getTitle();
            } else if (layoutViewId == R.id.details) {
                StringBuilder sb = new StringBuilder();
                if (this.getTown() != null) {
                    sb.append("Oras: ").append(this.getTown()).append(", ");
                }
                if (this.getStreat() != null) {
                    sb.append("Str.: ").append(this.getStreat()).append(", ");
                }
                if (this.getNo() != null) {
                    sb.append("Nr.: ").append(this.getNo()).append(", ");
                }
                if (this.getBuilding() != null) {
                    sb.append("Bl.: ").append(this.getBuilding()).append(", ");
                }
                if (this.getBuilding() != null) {
                    sb.append("Sc.: ").append(this.getStairs()).append(", ");
                }
                if (this.getZipCode() != null) {
                    sb.append("C.P.: ").append(this.getZipCode()).append(", ");
                }
                if (this.getDetails() != null) {
                    sb.append("Detalii: ").append(this.getDetails()).append(", ");
                }
                sb.setLength(sb.length() - 2);
                return sb.toString();
            }
        }
        return "";
    }
}